<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>意见管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		
		<link href="/static/weichat/css/style.css" rel="stylesheet" type="text/css" media="all" />
		<link rel="stylesheet" type="text/css" href="/static/manage/common/bootstrap/js/bootstarp-3.3.7/css/bootstrap.min.css" />
		<script src="/static/manage/common/bootstrap/js/jquery-3.2.0.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/manage/common/bootstrap/js/bootstarp-3.3.7/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="/static/manage/common/bootstrap/js/bootstarp-table-1.11.1/bootstrap-table.min.css" />
		<script src="/static/manage/common/bootstrap/js/bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/manage/common/bootstrap/js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>
	
	</head>
	<body>
		<form class="form-inline" action="/bisshop/" method="post">
		<p align="left">
  			<div class="form-group">
   			 	<label for="exampleInputName2">手机号码:</label>
    			<input type="text" class="form-control" id="mobile" name="mobile"  style="width:130px;height:32px;" placeholder="请输入手机号">
  			</div>
  			<div class="form-group">
    			<label for="exampleInputName2">内容:</label>
    			<input type="text" class="form-control" id="content" name="content" style="width:130px;height:32px;" placeholder="请输入搜索内容">
  			</div>
  			
  			<div class="form-group">
    			<label for="exampleInputName2">发送日期:</label>
    			<input type="date" class="form-control" id="start"  style="width:135px;height:32px;">
    			--至--
    			<input type="date" class="form-control" id="end"  style="width:135px;height:32px;" >
  			</div>
  			
  			<button type="button" class="btn btn-primary" id="butt">搜索</button>
  			<button type="reset" class="btn btn-primary" id="butt2">重置</button>
  		</p>
		</form>
		
		<!--查看意见的模态框-->
		<div class="modal fade" tabindex="-1" id="myModal" role="dialog">
  		<div class="modal-dialog" role="document">
   		 <div class="modal-content">
      			<div class="modal-header">
       		 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        		<h4 class="modal-title">查看意见</h4>
     		 </div>
      		<div class="modal-body">
        			
        <form class="form-inline" id="fm">
    			<table class="table table-bordered">
 					<input type="hidden" class="form-control" id="opinion_id"  name="opinion_id" value="">
 				 	<tr>
 				 		<td align="right">手机号:</td>
 				 		<td>
 				 			<input type="text" class="form-control" id="mobile2"  name="mobile" value="">
 				 		</td>
 				 	</tr>
 				 	<tr>
 				 		<td align="right">发送时间:</td>
 				 		<td>
 				 			<input type="text" class="form-control" id="create_time2"  name="create_time" value="">
 				 		</td>
 				 	</tr>
 				 	<tr>
 				 		<td align="right">内容:</td>
 				 		<td>
 				 			<input type="text" class="form-control" id="content2"  name="content" value="">
 				 		</td>
 				 	</tr>
				</table>
      	</form>
        				
     		 </div>
      		<div class="modal-footer">
       			 <p align="center"><button type="button" class="btn btn-default" data-dismiss="modal">关闭</button></p>
     		 </div>
    	</div><!-- /.modal-content -->
 	 </div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
		
		<div>
			<table id="table">

			</table>
		</div>
	</body>
	<script type="text/javascript">
		
		$(function() {
				

				//1.初始化Table

				var oTable = new TableInit();

				oTable.Init();

				
			});
		
		var TableInit=function(){
					var oTableInit=new Object();
					//初始化table
					oTableInit.Init=function(){
						
					
					
				$("#table").bootstrapTable({
					method:'get',
					url:"/bisopinion/",	//请求后台的url（*）
						striped: true, //是否显示行间隔色

						locale: 'zh-CN', //中文支持

						pagination: true, //是否开启分页（*）

						pageNumber: 1, //初始化加载第一页，默认第一页

						pageSize: 3, //每页的记录行数（*）

						pageList: [2, 3, 4], //可供选择的每页的行数（*）

						sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）

						/* showRefresh: true, //刷新按钮 */

						queryParams: oTableInit.queryParams, //传递参数（*）

						strictSearch: true,

						/* showColumns: true, //是否显示所有的列 */

						/* showRefresh: true, //是否显示刷新按钮 */

						minimumCountColumns: 2, //最少允许的列数

						/* clickToSelect: true, //是否启用点击选中行 */

						uniqueId: "project_id", //每一行的唯一标识，一般为主键列

						columns: [{
							field: 'mobile',
							title: '手机号码',
							align: 'center',
						},{
							field: 'content',
							title: '内容',
							align: 'center',
						},{
							field: 'create_time',
							title: '发送时间',
							align: 'center',
							formatter: function (value, row, index) {
                				return changeDateFormat(value)
							}
						},{
							title: '操作',
							align: 'center',
							formatter : function(v,r,i){
								return '<button onclick="dele('+r.opinion_id+')" class="btn btn-warning">删除<span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button><button onclick="sele('+r.opinion_id+')" class="btn btn-warning" data-toggle="modal" data-target="#myModal">查看详情</button>'
							}
						}]
					});
				};
			
					//得到查询的参数

					oTableInit.queryParams = function(params) {

						var temp = { //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
							
							limit: params.limit, //页面大小
							offset: params.offset, //偏移量
							pageSize:params.limit,
							//写模糊查询的参数
							mobile:$("#mobile").val(),
							content:$("#content").val(),
							start:$("#start").val(),
							end:$("#end").val()
							
						};
						return temp;
					};
					return oTableInit;
				};
				
				//删除
				function dele(opinion_id){
					
					$.ajax({
						
						type:"post",
						url:"/bisopinion/del/"+opinion_id,
						dataType:"json",
						success:function(data){
								$("#table").bootstrapTable('refresh');
						},
						
					})
				}
				
				//查看意见
				function sele(opinion_id){
					$.ajax({
						type:"post",
						url:"/bisopinion/seleBisopin",
						data:{
							opinion_id:opinion_id
						},
						success:function(data){
							
							$("#opinion_id").val(data.opinion_id),
							$("#mobile2").val(data.mobile),
							$("#create_time2").val(changeDateFormat(data.create_time)),
							$("#content2").val(data.content)
						}
					})
				}
				
				//模糊查询刷新
				$('#butt').click(function(){
					$("#table").bootstrapTable('refresh');
				})
		
		
	</script>
	<script type="text/javascript">
	function changeDateFormat(cellval) {
        var dateVal = cellval + "";
        if (cellval != null) {
            var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10));
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            
            var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
            var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
            var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
            
            return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + seconds;
        }
   }
	</script>
</html>
